import { baseUrl } from '../service/index.js'
import httpHelper from '../utils/helper/httpHelper.js'

// 账号
export const Account = {
  // 登录
  login(params, successFun, scope) {
    let headers = {
      'Authorization': 'Basic b3NjLWNsaWVudC1jbGllbnQ6b3NjLWNsaWVudC1zZWNyZXQ=',
      'Content-Type': 'application/json;charset=UTF-8'
    }
    return httpHelper.request(
      {
        url: baseUrl + 'oauth/token',
        method: 'POST',
        params: params,
        headers: headers,
        successFun: successFun
      },
      scope
    )
  },
  // 修改密码
  changePassword(params, successFun, scope) {
    return httpHelper.request(
      {
        url: baseUrl + 'account/changePassword',
        method: 'POST',
        params: params,
        successFun: successFun
      },
      scope
    )
  },
  // 检查账号是否存在
  checkExist(params, successFun, scope) {
    return httpHelper.request(
      {
        url: baseUrl + 'account/checkExist',
        method: 'POST',
        params: params,
        successFun: successFun
      },
      scope
    )
  },
  // 注册
  register(params, successFun, scope) {
    return httpHelper.request(
      {
        url: baseUrl + 'account/register',
        method: 'POST',
        params: params,
        successFun: successFun
      },
      scope
    )
  },
  // 重置密码
  resetPassword(params, successFun, scope) {
    return httpHelper.request(
      {
        url: baseUrl + 'account/resetPassword',
        method: 'POST',
        params: params,
        successFun: successFun
      },
      scope
    )
  },
  // 发送验证码
  sendVerifyCode(params, successFun, failedFun, scope) {
    return httpHelper.request(
      {
        url: baseUrl + 'account/sendVerifyCode',
        method: 'POST',
        params: params,
        successFun: successFun,
        failedFun: failedFun
      },
      scope
    )
  }
}